package com.glepoch.springbootsecuritymybatis.bean;

import com.glepoch.springbootsecuritymybatis.compoment.constant.statuscode.BaseStatusEnum;
import com.glepoch.springbootsecuritymybatis.compoment.constant.statuscode.NormalStatusCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description: 统一响应分页数据实体类
 * @author: ygl
 * @time: 20201204
 */
@Data
@AllArgsConstructor
@NoArgsConstructor

//@ApiModel(description = "统一响应分页数据实体类")
public class PageResultVO<T> extends RespResultVO<T> {
    //@ApiModelProperty("总记录数")
    private Long total;
    //@ApiModelProperty("PC端起始行号/手机端起始页")
    private Integer start;
    //@ApiModelProperty("页宽")
    private Integer limit;

    public PageResultVO(int code, String message, T data){
        super(code,message,data);
    }
    public PageResultVO(int code, String message){
        super(code,message);
    }

    public static <T> PageResultVO success(int code, String message, T data) {
        return new PageResultVO(code, message, data);
    }

    public static PageResultVO success(int code, String message) {
        return new PageResultVO(code, message);
    }

    public static PageResultVO success(String message) {
        return success(NormalStatusCode.SUCCESS.getCode(), message);
    }


    public static PageResultVO success(BaseStatusEnum baseStatusEnum) {
        return new PageResultVO(baseStatusEnum.getCode(), baseStatusEnum.getMessage());
    }

    public static PageResultVO success() {
        return new PageResultVO(NormalStatusCode.SUCCESS.getCode(), NormalStatusCode.SUCCESS.getMessage());
    }

    public static <T> PageResultVO success(int total, T data) {
        return success(NormalStatusCode.SUCCESS.getCode(), NormalStatusCode.SUCCESS.getMessage(), data);
    }

    public static <T> PageResultVO fail(int code, String message, T date) {
        return new PageResultVO(code, message,date);
    }

    public static PageResultVO fail(int code, String message) {
        return new PageResultVO(code, message);
    }

    public static PageResultVO fail(BaseStatusEnum baseStatusEnum) {
        return fail(baseStatusEnum.getCode(), baseStatusEnum.getMessage());
    }

    public static PageResultVO fail(String message) {
        return fail(NormalStatusCode.FAIL.getCode(), message);
    }

    public static PageResultVO fail() {
        return fail(NormalStatusCode.FAIL.getCode(), NormalStatusCode.FAIL.getMessage());
    }
}
